package com.wjh.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.wjh.user.entity.UserEntity;
import com.wjh.user.request.QueryUserPageRequest;

/**
 * 用户Mapper
 * 
 * @author wenjianhai
 * @date 2023/6/21
 * @since JDK 17
 */
@Mapper
public interface IUserMapper {
	void save(UserEntity user);

	void update(UserEntity user);

	void deleteById(Long id);

	void deleteByGuid(String userGuid);

	UserEntity queryById(Long id);

	UserEntity queryByGuid(String userGuid);

	List<UserEntity> queryAll();

	List<UserEntity> queryByMap(@Param("param") Map<String, Object> params);

	Integer queryCount(@Param("param") Map<String, Object> params);

	Integer queryCountForPage(@Param("req") QueryUserPageRequest request);

	List<UserEntity> page(@Param("req") QueryUserPageRequest request, @Param("pageSize") int pageSize,
			@Param("offset") int offset);

	Integer isUserCodeExist(String userCode);

	UserEntity queryByLoginName(String loginName);

	UserEntity queryByUserCode(String userCode);

	UserEntity queryByUserCodeForUpdate(String userCode);

	/**
	 * 增加用户可用金额
	 *
	 * @date 2023-06-29
	 * @param userGuid 用户Guid
	 * @param amount   金额
	 * @since JDK 17
	 * @author wenjianhai
	 */
	void addAmount(@Param("userGuid") String userGuid, @Param("amount") Long amount);

	/**
	 * 扣除用户可用金额
	 *
	 * @date 2023-06-29
	 * @param userGuid 用户Guid
	 * @param amount   金额
	 * @since JDK 17
	 * @author wenjianhai
	 */
	void deductAmount(@Param("userGuid") String userGuid, @Param("amount") Long amount);
}
